<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8" />
  <title></title>
</head>

<body>
 
</body>
</html>
<script>
  //餐厅类
  function Diningroom(money,seat,worker){
      this.money = money
      this.seat = seat
      this.worker = worker
      this.recruit= function(obj){
        console.log('招聘方法')
        this.worker.push(obj)
      }
      this.fire = function(obj){
        console.log('解雇方法')
        for(let i=0;i<this.worker.length;i++){
          if(obj.id == this.worker[i].id){
            this.worker.splice(i,1)
            return
          }
        }
      }
  }
  // 职员类
  function Worker(id,name,pay){
       this.id = id
       this.name = name
       this.pay = pay 
       this.isArry = function(obj){
          return Object.prototype.toString.call(obj)== '[object Array]';
       }
  }
  Worker.prototype.complete = function(obj){
      console.log(typeof obj )
      if(this.type == 1){
        if(this.isArry(obj)){
          console.log('服务员记录客人点菜')
          return
        }
        console.log('服务员上菜')
       
      }else if(this.type == 2){
        console.log('厨师的一次工作')
      }
        
  }
  // 服务员类
  function Waiter(id,name,pay){
    Worker.call(this,id,name,pay)
    this.type = 1
  }
  Waiter.prototype = Object.create(Worker.prototype);
  
  // 厨师类
  function Cooker(id,name,pay){
    Worker.call(this,id,name,pay)
    this.type = 2

  }
  Cooker.prototype = Object.create(Worker.prototype);
  // 顾客类
  function Visitor(){
     this.order = function(){
       console.log('顾客点菜')
     }
     this.eat = function(){
       console.log('顾客吃')
     }
  }
  // 菜品类
  function Food(name,cost,price){
       this.name = name
       this.cost = cost
       this.price = price
  }

  var canting = new Diningroom(1000,10,[])
  var newWaiter = new Waiter(1,'小李','1000')
  var newCooker = new Cooker(2,'小厨师','3000')
  newWaiter.complete([])
  canting.recruit(newWaiter)
  canting.recruit(newCooker)
  canting.fire(newCooker)
  console.log(canting.worker)
</script>
